﻿/** 
 * Copyright 2010 NUMKIT.COM (contact: opensource@numkit.com)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 * 
 * @author 陈超
 * @version 1.0
 */
import flash.external.ExternalInterface;
class DrawPanel {
	public static var FlashObjID:Number;
	public static var tipTF:TextField;
	public static var rootMC:MovieClip;
	private var config:Config;
	private var lineData:Data;
	public function DrawPanel(root:XMLNode) {
		if (root.nodeName != "chart") {
			throw new Error("Can't find root node chart!");
		}
		config = new Config(root.firstChild);
		lineData = new Data(root.lastChild);
	}
	public function draw(rootMC:MovieClip):Void {
		DrawPanel.rootMC = rootMC;
		//绘制背景
		var background:Background = new Background();
		background.draw(rootMC, config);
		//绘制折线
		var aPolyline:Array = lineData.aPolyline;
		for (var i:Number = 0; i<aPolyline.length; i++) {
			var mc:MovieClip = rootMC.createEmptyMovieClip("polyline"+i, rootMC.getNextHighestDepth());
			aPolyline[i].draw(mc, config);
		}
		//tipTextField
		tipTF = rootMC.createTextField("tipTF", rootMC.getNextHighestDepth(), -100, -100, 50, 18);
		tipTF.selectable = false;
		tipTF._visible = false;
	}
}
